﻿<?php 
    @session_start();
	if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: cnk-dangnhap.php");
	}
	include "connect.php"; ?>
<?php
	include("pChart/pData.class");
	include("pChart/pChart.class");
	function createChar($dt1,$dt2,$dt3,$dt4,$mamon)
	{
		// Dataset definition 
		 $DataSet = new pData;
		 $DataSet->AddPoint($dt1,"Serie1");
		 $DataSet->AddPoint($dt2,"Serie2");
		 $DataSet->AddPoint($dt3,"Serie3");
		 $DataSet->AddPoint($dt4,"Serie4");
		 $DataSet->AddAllSeries();
		 $DataSet->SetAbsciseLabelSerie();
		 $DataSet->SetSerieName("Khong hai long","Serie1");
		 $DataSet->SetSerieName("Hai long","Serie2");
		 $DataSet->SetSerieName("Rat hai long","Serie3");
		 $DataSet->SetSerieName("Xuat sac","Serie4");
		
		 // Initialise the graph
		 $Test = new pChart(850,300);
		 $Test->setFontProperties("Fonts/times_1.ttf",8);
		 $Test->setGraphArea(50,30,680,250);
		 $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
		 $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
		 $Test->drawGraphArea(255,255,255,TRUE);
		 $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);
		 $Test->drawGrid(4,TRUE,230,230,230,50);
		
		 // Draw the 0 line
		 $Test->setFontProperties("Fonts/times_1.ttf",6);
		 $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
		
		 // Draw the bar graph
		 $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE,80);
		
		
		 // Finish the graph
		 $Test->setFontProperties("Fonts/times_1.ttf",13);
		 $Test->drawLegend(700,200,$DataSet->GetDataDescription(),255,255,255);
		 $Test->setFontProperties("Fonts/times_1.ttf",10);
		 $Test->drawTitle(50,22,$mamon,50,50,50,585);
		 $Test->Render("bieudo/image/".$mamon.".png");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Báo Cáo Kết Quả Đánh Giá Toàn Khoa</title>
<script src="ajax/pdf.js" language="javascript"></script>
<style type="text/css">

a	{
		color: #006600;
		text-decoration: none;
	}

a:hover { COLOR:#FF0000}

.style2 {
	font-size: 18px;
	font-weight: bold;
	color: #FFFFFF;
}
.style3 {font-size: 14px; font-weight: bold; color: #FFFFFF; }
.style4 {
	color: #000099;
	font-weight: bold;
	font-size:20px;
}
.style5 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 30px;
}
.bg {	border-right-color:#0066FF;
		border-bottom-color:#0066FF;
	}

.bg1 {	border-bottom-color:#0066FF;}

.bg2 {	border-top-color:#0066FF;}

.bg3 {	border-left-color:#0066FF;}

.bg4 {	border-right-color:#0066FF;}
.mo	{	color:#0000FF;	}
.style6 {
	
	color: #000099;
}
.style7{
	font-size: 20px;
	font-weight: bold;
}
</style>
<script language="javascript">
	function openUrl(a)
	{
		var win = window.open(a,'Buy ticket',
			'width=' + 1400 + ', height=' + 900 + ', ' +
			'left=' + 0 + ', top=' + 0 + ', ' +
			'location=no, menubar=no, ' +
			'status=no, toolbar=no, scrollbars=yes, resizable=no');
	}
</script>
</head>
<body>
<?php
        if($_GET["act"] == "in")
		  {
			$cnk = $_GET["cnk"];
		  }
		  else
		  {
			$cnk=$_SESSION['cnk'];
		  }
       // $cnk=$_SESSION['cnk']; 
        $sql=mysql_query("select * from khoa where username='$cnk'");
		$r=mysql_fetch_row($sql);
		$tenkhoa=$r[1];
		$makhoa=$r[0];
      
	  $hknk=$_REQUEST["ma"];
	  $tam=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk' ");
	  $t=mysql_fetch_row($tam);
	  $hk=$t[1];$nk=$t[2];
	  
?>
<!-- đầu trang -->
<?php
		            $kq=mysql_query("select extract(day from curdate()),extract(month from curdate()),extract(year from curdate()) "); 
					while ($r=mysql_fetch_row($kq))
					{
						$ngay=$r[0];
						$thang=$r[1];
						$nam=$r[2];
					}
		  ?>  
<?php // convert image to dataURL
$img_source = "image/logo.gif"; // image path/name
$img_binary = fread(fopen($img_source, "r"), filesize($img_source));
$img_string = "data:image/gif;base64,".base64_encode($img_binary);
?>

	<div align="right">
	<a href="#" onclick="openUrl('exportPDF.php<?php echo "?type=cnktoankhoa&cnk=".$cnk."&ma=".$_REQUEST["ma"]."&act=in"; ?>');"/>Mẫu In  <?php echo $ngay; ?>/<?php echo $thang; ?>/<?php echo $nam; ?></a></div>

	<tr> <td width="900">
   	  <table width="100%" border="0">
	  
	     <tr>
		    <td  rowspan="2" width="100" style="border:none"><img src="<?php echo $img_string; ?>" height="70" width="100" /></td>
            <td colspan="2" style="border:none"><div align="left" style="font-size:18px; font-weight:bold" class="style6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRƯỜNG ĐẠI HỌC CẦN THƠ</div></td>
            <td colspan="3" style="border:none"><div align="center" style="font-size:18px; font-weight:bold;" class="style6">CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM</div></td>
          </tr>
          
          <tr>
            <td colspan="2" style="border:none"><div align="left" style="font-size:18px; font-weight:bold;" class="style6">Khoa <?php echo $tenkhoa; ?> </div></td>
            <td colspan="3" style="border:none"><div align="center" style="font-size:18px; font-weight:bold" class="style6" >Độc lập - Tự do - Hạnh phúc </div></td>
          </tr>
          
          <tr>
            <td width="100" style="border:none">&nbsp;</td>
			<td width="294" style="border:none" >&nbsp;</td>
			<td width="131" style="border:none" >&nbsp;</td>
            <td width="215" style="border:none">&nbsp;</td>
            <td width="108" class="bg2" style="border:none">&nbsp;</td>
            <td width="218" style="border:none">&nbsp;</td>
          </tr>
		
		<tr>
		         <td colspan="6" style="font-size:24px; font-weight:bold; border:none;" class="style6" align="center">
				                TRƯỜNG ĐẠI HỌC CẦN THƠ
				 </td>
		</tr>
		<tr>
		         <td colspan="6" style="font-size:24px; font-weight:bold; border:none;" class="style6" align="center">
				                KHOA  
								<?php   
								       $up=mysql_query("select upper('$tenkhoa') from dual");
									   $up1=mysql_fetch_row($up);
									   $tk=$up1[0];
									   echo $tk;
								?>
				 </td>
		</tr>
		<tr>
		         <td colspan="6" style="font-size:30px; font-weight:bold; border:none;" class="style6" align="center">
				                KẾT QUẢ NHẬN XÉT HỌC PHẦN HỌC KÌ <?php echo $hk; ?> NĂM HỌC <?php echo $nk; ?>
				 </td>
		</tr>
		<tr><td colspan="6" height="30">&nbsp;</td> </tr>
	<!-- Bo mon -->
	 <?php 
	   
							    $sql=mysql_query(" select count(*) from `lop hoc phan` where ma_hknk='$hknk' and ma_gv in (select ma_gv from `giang vien` a,`bo mon` b,`khoa` c where a.ma_bm=b.ma_bm and b.ma_khoa=c.ma_khoa and c.ma_khoa='$makhoa' ) ");
							   $sql1=mysql_fetch_row($sql);
							   $lop=$sql1[0];$dem=0;$dem1=0;
				
							   $sql2=mysql_query("select * from `danh gia` where ma_hknk='$hknk' and ma_hp in (select ma_hp from `lop hoc phan` a,`giang vien` b,`bo mon` c, `khoa` d where a.ma_gv=b.ma_gv and b.ma_bm=c.ma_bm and c.ma_khoa=d.ma_khoa and d.ma_khoa='$makhoa'  and a.ma_hknk='$hknk') group by ma_sv,ma_hknk,stt_nhom,ma_hp");
							   while ($sql3=mysql_fetch_row($sql2))
							   {
									  $dem++;
							   }
	  ?>
		                 <tr>
							   <td width="20">&nbsp;</td>
							   <td height="40" colspan="4"  style="font-size:20px;  border:none;"  align="justify"valign="bottom">
	
								<strong>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Khoa / Viện: <?php echo $tenkhoa; ?></strong>
								  <br />
								 
								  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Tổng số sinh viên tham gia đánh giá: <?php echo $dem; ?>
								  <br />
								  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Tổng số lớp học phần: <?php echo $lop; ?><br /><br />
								</td>
								<td width="20" >&nbsp;</td>
						  </tr>
						  
						   <tr>
								
								<td colspan="6" style="font-size:20px">
													  <table width="1000" align="center" cellspacing="0" border="1" bordercolor="#0066FF" cellpadding="0">
															
															
																			
															<tr align="center" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
																<td width="400" height="40" class="bg" rowspan="2" ><span class="style7">Nội Dung Đánh Giá</span>				
																</td>
																<td width="150" class="bg" colspan="2"><span class="style7">Chưa Hài Lòng</span>			   
																</td>
																<td width="150" class="bg" colspan="2">
																		  <span class="style7">Hài Lòng</span>				
																</td>
																<td width="150" class="bg" colspan="2">
																		  <span class="style7">Rất Hài Lòng</span>				
																</td>
																<td width="150" class="bg1" colspan="2">
																		  <span class="style7">Xuất Sắc</span>				
																</td>
																
															</tr>
															<tr bgcolor="#CCCCCC">
																 
																 <td align="center">
																	   Số lượng
																 </td>
																 <td align="center">
																	   Tỉ lệ(%)
																 </td>
																 
																 <td align="center">
																	   Số lượng
																 </td>
																 <td align="center">
																	   Tỉ lệ(%)
																 </td>
																 
																 <td align="center">
																	   Số lượng
																 </td>
																 <td align="center">
																	   Tỉ lệ(%)
																 </td>
																 
																 <td align="center">
																	   Số lượng
																 </td>
																 <td align="center">
																	   Tỉ lệ(%)
																 </td>
																 
																 
															</tr>
													        
															<?php
																$khl=array();
																$hl=array();
																$rhl=array();
																$xs=array();
														   
															
																$s=mysql_query("select a.ma_tc,a.noidung_tc from `tieu chi` a, `tieuchi hocki` b where a.ma_tc=b.ma_tc and b.ma_hknk='$hknk' ");
																
																while($row=mysql_fetch_row($s))
																{
																   $matc=$row[0];
																   $noidung=$row[1];
																   $s1=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hknk='$hknk' and ma_hp in (select ma_hp from `lop hoc phan` a,`giang vien` b,`bo mon` c, `khoa` d where a.ma_gv=b.ma_gv and b.ma_bm=c.ma_bm and c.ma_khoa=d.ma_khoa and d.ma_khoa='$makhoa'  and a.ma_hknk='$hknk')  and ma_tc='$matc' and `muc danh gia`='1' group by `muc danh gia`,ma_tc");
																   $s2=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hknk='$hknk' and ma_hp in (select ma_hp from `lop hoc phan` a,`giang vien` b,`bo mon` c, `khoa` d where a.ma_gv=b.ma_gv and b.ma_bm=c.ma_bm and c.ma_khoa=d.ma_khoa and d.ma_khoa='$makhoa' and  a.ma_hknk='$hknk') and ma_tc='$matc' and `muc danh gia`='2' group by `muc danh gia`,ma_tc");
																   $s3=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hknk='$hknk' and ma_hp in (select ma_hp from `lop hoc phan` a,`giang vien` b,`bo mon` c, `khoa` d where a.ma_gv=b.ma_gv and b.ma_bm=c.ma_bm and c.ma_khoa=d.ma_khoa and d.ma_khoa='$makhoa' and  a.ma_hknk='$hknk') and ma_tc='$matc' and `muc danh gia`='3' group by `muc danh gia`,ma_tc");
																   $s4=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  ma_hknk='$hknk' and ma_hp in (select ma_hp from `lop hoc phan` a,`giang vien` b,`bo mon` c, `khoa` d where a.ma_gv=b.ma_gv and b.ma_bm=c.ma_bm and c.ma_khoa=d.ma_khoa and d.ma_khoa='$makhoa' and a.ma_hknk='$hknk') and ma_tc='$matc' and `muc danh gia`='4' group by `muc danh gia`,ma_tc");
																   if(mysql_num_rows($s1)==0) $muc1=0;
																   else
																   {
																   $r1=mysql_fetch_row($s1);
																   $muc1=$r1[2];
																   }
																   if(mysql_num_rows($s2)==0) $muc2=0;
																   else
																   {
																   $r2=mysql_fetch_row($s2);
																   $muc2=$r2[2];
																   }
																   if(mysql_num_rows($s3)==0) $muc3=0;
																   else
																   {
																   $r3=mysql_fetch_row($s3);
																   $muc3=$r3[2];
																   }
																   if(mysql_num_rows($s4)==0) $muc4=0;
																   else
																   {
																   $r4=mysql_fetch_row($s4);
																   $muc4=$r4[2];
																   }
																   ?>
																   <tr bordercolor="#FFFFFF">
																	   <td class="bg" height="60" style="font-size:20px;">
																			 <?php echo "&nbsp;&nbsp; $matc. $noidung"; ?> 
																	   </td>
																	   
																	   <td align="center">
																			  <?php  echo $muc1; ?>
																	   </td>
															
																	   <td class="bg" align="center">
																			<?php
																			      if($dem==0) $dem1=1;
												                                  else $dem1=$dem;
																				  $t=($muc1/$dem1)*100;
																				  $t1=round($t,2);
																				  $khl[]=$t1; 
																				  echo " $t1  ";
																				  
																			?>
																	   </td>
																	   <td align="center">
																			  <?php echo $muc2; ?>
																	   </td>
																	   <td class="bg" align="center">
																		   <?php
																				   
																				  if($dem==0) $dem1=1;
												                                  else $dem1=$dem;
																				  $t=($muc2/$dem1)*100;
																				  $t1=round($t,2);
																				  $hl[]=$t1; 
																				  echo " $t1  ";
																			?>
																	   </td>
																	   <td align="center">
																			  <?php  echo $muc3; ?>
																	   </td>
																	   <td class="bg" align="center">
																			  <?php
																				  
																				  if($dem==0) $dem1=1;
												                                  else $dem1=$dem;
																				  $t=($muc3/$dem1)*100;
																				  $t1=round($t,2); 
																				  $rhl[]=$t1;
																				  echo " $t1  ";
																			 ?>
																	   </td>
																	   <td align="center">
																			  <?php echo $muc4; ?>
																	   </td>
																	   <td class="bg1" align="center">
																			  <?php
																				   if($dem==0) $dem1=1;
												                                   else $dem1=$dem;
																				   $t=($muc4/$dem1)*100;
																				   $t1=round($t,2);
																				   $xs[]=$t1; 
																				   echo " $t1  ";
																				   
																			?>
																	   </td> 
																		 
																   </tr>
																   <?php
																	  
																}//while
																
															 
												   ?>		
															
													</table>
		                       </td>
					   </tr>
					
					<tr>
					     <td colspan="6" height="30">&nbsp;
						 </td>
					</tr>
					<tr>
										<td  style="font-weight:bold" colspan="6">
												  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(%)
										</td>
										
					   </tr>
					<tr>
							  <td colspan="6" align="center">
									 <!-- bieu do -->
															
															 <?php
											
												createChar($khl,$hl,$rhl,$xs,$makhoa.$hknk);
												?>
					                        <?php // convert image to dataURL
													$img_source2 = "bieudo/image/$makhoa"."$hknk.png"; // image path/name
													$img_binary2 = fread(fopen($img_source2, "r"), filesize($img_source2));
													$img_string2 = "data:image/gif;base64,".base64_encode($img_binary2);
											?>
											
											
											<!--<img src="bieudo/image/<?php //echo $makhoa.$hknk.".png"; ?>" />-->
											<img src="<?php  echo $img_string2; ?>"  />
									<!-- /bieu do -->
							  </td>
				  </tr>
				  <tr>
													
													<td style="font-weight:bold; font-size:16px" align="right" colspan="6" >
													 Tiêu Chí&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													</td>
			      </tr> 
				  <tr>
				      <td colspan="6" height="30">&nbsp;
					               
					  </td>
				  </tr> 
				 
         <tr valign="top">
            <td height="30" colspan="6" style="border:none"> </td>
           
        </tr>
      </table>
    </td> 
	</tr>
</body>
</html>




